{extend name=".././view/createhref.html" /}

{block name="form"}
    <form action="{$list.set.url}" method="{$list.set.formpost}" class="layui-form layui-form-pane" lay-filter="myform">
      <div class="layui-form-item">
        <label for="school_id" class="layui-form-label"><span class="x-red">*</span>学校</label>
        <div class="layui-input-block">
          <select name="school_id" id="school" lay-verify="required">
            {foreach $list.school as $key=>$vo}
              <option value="{$vo.id}"> {$vo.title} </option>
            {/foreach}
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label for="ruxuenian" class="layui-form-label">
          <span class="x-red">*</span>年级
        </label>
        <div class="layui-input-block">
          <select name="ruxuenian" id="ruxuenian" lay-verify="required" class="layui-form-label" lay-filter="nianji">
            {foreach $list.nianji as $key=>$vo}
            	<option value="{$vo.ruxuenian}">
            		{$vo['nianjiname']}
            	</option>
            {/foreach}
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label for="banji" class="layui-form-label"> <span class="x-red">*</span>班级 </label>
        <div class="layui-input-block" id="banji">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="subject" class="layui-form-label"><span class="x-red">*</span>学科</label>
        <div class="layui-input-block" id="subject">
        </div>
      </div>
      <input type="hidden" id="kaoshi_id" name="kaoshi_id" value="{$list.set.kaoshi_id}">
      <div class="layui-form-item" style="text-align: right;">
          <button  class="layui-btn" lay-filter="" lay-submit="">
              {$list.set.butname}
          </button>
      </div>
  </form>
{/block}

{block name="myjs"}
<script>
layui.use(['form','cjgl'], function(){
	var form = layui.form
      cjgl = layui.cjgl;

  addBanji();
  addSubject();

  // 监听选择按钮
  form.on('select', function(data){
    addBanji();
    addSubject();
  });

  // 添加班级
  function addBanji(){
    // 获取参数
    formval = form.val("myform");
    cjgl.createCheckbox('banji', formval, '/tools/kscy/class', 'banji_id', 'banTitle');
  }


  // 添加学科
  function addSubject(){
    // 获取参数
    formval = form.val("myform");
    cjgl.createCheckbox('subject', formval, '/tools/kscy/subject', 'subject_id', 'title');
  }

});
</script>
{/block}

